package practice2;

public class good implements Runnable{

    static int goods = 100;
    @Override
    public void run() {
        while(true){
            synchronized (good.class){
                if(goods<10){
                    break;
                }else{
                    goods--;
                    Thread t = Thread.currentThread();
                    System.out.println(t.getName()+"送出了第"+(100-goods)+"份礼品,还剩下"+goods+"份商品");
                    Thread.yield();// 礼让线程,让出重新抢
                }
            }
        }
    }
}
